@extends('layouts.information')

@section('title','用户创建')

@section('content')
    <div class="panel-body">
        {!! Form::model($user,[
        'url'=>$user->id?route('user.update',['id'=>$user->id]):route('user.store'),
        'method'=>$user->id?'PUT':'POST',
        ]) !!}
        @if($user->canEditPower())
            <div class="form-group">
                {!! Form::label('password',trans('validation.attributes.password')) !!}
                {!! Form::password('password',['class'=>'form-control']) !!}
            </div>
            <div class="form-group">
                {!! Form::label('email',trans('validation.attributes.email')) !!}
                {!! Form::email('email',null,['class'=>'form-control']) !!}
            </div>
        @endif
        <div class="form-group">
            {!! Form::label('name',trans('validation.attributes.name')) !!}
            {!! Form::text('name',null,['class'=>'form-control']) !!}
        </div>
        <div class="form-group">
            {!! Form::label('mobile',trans('validation.attributes.mobile')) !!}
            {!! Form::text('mobile',null,['class'=>'form-control']) !!}
        </div>
        <div class="form-group">
            {!! Form::label('phone',trans('validation.attributes.phone')) !!}
            {!! Form::text('phone',null,['class'=>'form-control']) !!}
        </div>

        <div class="form-group">
            {!! Form::label('sex',trans('validation.attributes.sex')) !!}
            {!! Form::radio('sex','男',['class'=>'form-control']) !!}男
            {!! Form::radio('sex','女',['class'=>'form-control']) !!}女
        </div>
        <div class="form-group">
            {!! Form::label('duty',trans('validation.attributes.duty')) !!}
            {!! Form::text('duty',null,['class'=>'form-control']) !!}
        </div>
        @if($user->canEditPower())
            <div class="form-group">
                {!! Form::label('depart_id',trans('validation.attributes.depart')) !!}
                {!! Form::select('depart_id',$departs) !!}
            </div>
            <div class="form-group">
                {!! Form::label('role_id',trans('validation.attributes.role')) !!}
                {!! Form::select('role_id',$roles) !!}
            </div>
            <div class="form-group">
                {!! Form::label('on_job',trans('validation.attributes.on_job')) !!}
                @foreach($user->dropdown('on_job') as $value=>$label)
                    {!! Form::radio('on_job',$value,['class'=>'form-control']) !!}{{$label}}
                @endforeach
            </div>
        @endif
        <div class="form-group">
            {!! Form::label('start_at',trans('validation.attributes.start_at')) !!}
            {!! Form::date('start_at',null,['class'=>'form-control']) !!}
        </div>
        <div class="form-group">
            {!! Form::label('unit_start_at',trans('validation.attributes.unit_start_at')) !!}
            {!! Form::date('unit_start_at',null,['class'=>'form-control']) !!}
        </div>
        {!! Form::submit('提交') !!}
        {!! Form::close() !!}
    </div>
@endsection

@section('scripts')
    @if ($errors->any())
        <script>
            alert('{{ current($errors->all()) }}');
        </script>
    @endif
@endsection